<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: Admin
  Date: 2016/8/12
  Time: 10:26
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<html>
<head>
    <title>Title</title>
    <style type="text/css">
        p {color: red}
    </style>
</head>
<body>
<center>
<c:if test="${empty sessionScope.ShoppingCart.books}">
    <p>亲爱的 &nbsp;${sessionScope.user}&nbsp;您的购物车还是空的呦,赶紧去购物吧!</p>
</c:if>
<c:if test="${param.title != null}">
    您已经将 ${param.title} 放入到购物车中.
    <br><br>
</c:if>
<c:if test="${!empty sessionScope.ShoppingCart.books}">
    您的购物车中有${sessionScope.ShoppingCart.bookNumber}件商品.
    <a href="/shopping/list?pageNo=${bookPage.pageNo}">查看购物车</a>
</c:if>
<br><br><br><br>
    <h2>网上书城</h2><br><br>
<form action="/book/list" method="post" id="search">
    按价格查找:
    <input type="hidden" name="pageNo" value="1">
    <input type="number" name="minPrice" value="${param.minPrice}"/>-
    <input type="number" name="maxPrice" value="${param.maxPrice}"/>
    <a href="javascript:;" page="1">查询</a>
</form>
<br><br>
<table cellpadding="10">
    <a href="/addBook.jsp">添加图书</a>
    <c:forEach items="${bookPage.list}" var="book">
        <tr>
            <td>
                <a href="/book/detail?id=${book.id}">${book.title}</a>
                <br>
                ${book.author}
            </td>
            <td>${book.price}</td>
            <td><a href="/book/addToCart?pageNo=${bookPage.pageNo}&id=${book.id}&title=${book.title}">加入购物车</a></td>
        </tr>
    </c:forEach>
    <br><br>
    <tr>
        <td><a href="javascript:;" page="1">首页</a>|
        </td>
        <td><a href="javascript:;" page="${bookPage.prevPage}">上一页</a>|
        </td>
        <td><a href="javascript:;" page="${bookPage.nextPage}">下一页</a>|
        </td>
        <td><a href="javascript:;" page="${bookPage.totalPageNumber}">尾页</a>
        </td>
        <td><a>第${bookPage.pageNo} 页/ 共 ${bookPage.totalPageNumber}页(共${bookPage.totalItemNumber} 条)</a>
        </td>
    </tr>
</table>


<script type="text/javascript" src="/script/jquery-1.7.2.js"></script>
<script type="text/javascript">
    $("a[page]").click(function () {
        var page = $(this).attr("page");
        $("input[name=pageNo]").val(page);
        $("#search").submit();
    });
</script>
</center>
</body>
</html>
